home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / System / Felix 1.1 / Felix cdev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-16  |  983 b   |  50 lines  |  [TEXT/KAHL]

  1. /* Cdev interface for Felix. June 30th, 1993 */
  2. /* Uses the THINK C supplied object class, which makes things very simple */
  3.  
  4. #include "cdev.h"
  5.  
  6. class FelixCdev : public cdev {
  7.     public : 
  8.     virtual void ItemHit (short item);    
  9. };
  10.  
  11.  
  12. /* Runnable - should the cdev appear in the Control Panel? This implements the "macDev" message. */
  13. /* Here we demand System 7 */
  14.  
  15. Boolean Runnable()
  16. {
  17.     OSErr         e;
  18.     SysEnvRec     env;
  19.  
  20.     e = SysEnvirons(1, &env);
  21.     return (env.systemVersion >= 0x700);
  22. }
  23.  
  24. /* New - create the cdev object */
  25.  
  26. cdev* New()
  27. {
  28.     return (new (FelixCdev));
  29. }
  30.  
  31. /* ItemHit has to be overriden to define our behavior. Here we have a single button */
  32.  
  33. void FelixCdev::ItemHit(short item)
  34. {
  35.     StandardFileReply        reply;
  36.     SFTypeList            dummy;
  37.     Handle                h;
  38.  
  39.     if (item == 1) {
  40.         StandardGetFile(nil, -1, dummy, &reply);
  41.         if (reply.sfGood) {
  42.             h = GetResource('DDIR', 0);
  43.             if (!ResError()) {
  44.                 * (long*) (*h) = reply.sfFile.parID;
  45.                 ChangedResource(h);
  46.             }
  47.             else SysBeep(0);
  48.         }
  49.     }
  50. }